<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/artdialog/artDialog.js?skin=simple'); ?>"></script>
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/artdialog/plugins/iframeTools.js'); ?>"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $this->basePath('public/css/dbblack/js/form/style.css'); ?>"/>
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/form/form.js'); ?>"></script>
<div class="simple-box " style="width:600px;margin:40px auto;" >
        <?php
        if (isset($this->message) and $this->message != '') {
            echo '<br><h4>' . $this->message . '</h4>';
        } elseif(isset($this->step) and $this->step == 2){ ?>
            <form action="<?php echo $this->url('frontuser/default',array('action'=>'phoneforgotpasswdedit')); ?>" method="post">
                <input type="hidden" name="step" value="step3">
                <ul class="form">
                    <li>
                        <span class="perfix fa">&#xf007;</span><input class="input" disabled value="<?php echo $this->escapeHtml($this->user_name); ?>">
                    </li>
                    <li><span class="perfix fa">&#xf10b;</span><input  class="input" disabled value="<?php echo $this->escapeHtml($this->user_phone); ?>"><label></label></li>
                    <li><span class="perfix fa">&#xf02a;</span><input type="text" class="input-sm" name="phone_code" id="phone_code"  maxlength="6" style="width: 80px;" pattern="\w{6}" placeholder="<?php echo $this->translate('手机验证码'); ?>"><input type="button" id="get_phone_code" value="<?php echo $this->translate('点击获取验证码'); ?>"></li>
                    <li><input type="submit" class="btn btn-main" value="<?php echo $this->translate('下一步'); ?>"></li>
                </ul>
            </form>
        <?php } else { ?>
        <form action="" method="post">
            <ul class="form">
                <li><?php echo $this->translate('手机号码'); ?> &nbsp;|&nbsp; <a href="<?php echo $this->url('frontuser/default',array('action'=>'forgotpasswd')); ?>" class="btn btn-gray"><?php echo $this->translate('点击通过电子邮件重置'); ?></a></li>
                <li><span class="perfix fa">&#xf10b;</span><input name="user_phone" id="user_phone"  class="input" pattern="phone" placeholder="<?php echo $this->translate('输入注册时的手机号码'); ?>" alt="<?php echo $this->translate('请输入手机号码！'); ?>"><label></label></li>
                <li><span class="perfix fa">&#xf02a;</span><input type="text" class="input-sm" name="captcha_code" id="captcha_code"  pattern="\w{5}" maxlength="5" style="width: 80px;" placeholder="<?php echo $this->translate('验证码'); ?>"><span id="forgot_captcha_id"></span></li>
                <li><input type="submit" class="btn btn-main" value="<?php echo $this->translate('下一步'); ?>"></li>
            </ul>
        </form>
        <?php } ?>

</div>
<script type="text/javascript">
    <?php if(isset($this->step) and $this->step == 2){ ?>
    var waittime = 60;
    function captchatime() {
        if (waittime == 0) {
            $('#get_phone_code').removeAttr("disabled");
            $('#get_phone_code').val('<?php echo $this->translate('发送验证码'); ?>');
            waittime = 60;
        }
        else {
            $('#get_phone_code').val("<?php echo $this->translate('重新发送'); ?>(" + waittime + ")");
            waittime--;
            setTimeout(function() {
                    captchatime()
                },
                1000)
        }
    }
    document.getElementById("get_phone_code").onclick=function(){
        $.ajax({
            type : 'POST',
            url	 : '<?php echo $this->url('frontuser/default',array('action'=>'sendPhoneCode')); ?>',
            success: function(msg){
                if(msg != '') {
                    alert(msg);
                    return false;
                } else {
                    $('#get_phone_code').attr("disabled", true);
                    captchatime();
                }
            }
        });
    }
    <?php } else { ?>
    $("input[name='captcha_code']").on("change",function(event){
        if(autoValidate.validate(event)){
            $.post("<?php echo $this->url('shopfront/default/captcha-check',array('action'=>'captcha','captcha_check'=>1)); ?>",{captcha_code:$(this).val()},function(data){
                if(data == 'false') {
                    autoValidate.showMsg({id:document.getElementById('captcha_code'),error:true,msg:'<?php echo $this->translate('验证码错误！'); ?>'});
                }
            });
        }
    });
    //验证码添加
    function captchaAdd() {
        $.get("<?php echo $this->url('shopfront/default',array('action'=>'captcha')); ?>",'',
            function(data){
                $("#forgot_captcha_id").html('<img src="<?php echo $this->basePath('/'); ?>'+data.captcha_file+'" border="0" >&nbsp;&nbsp;<a href="javascript:;" onclick="captchaAdd()"><?php echo $this->translate('更换验证码'); ?></a>');
            },'json');
    }
    captchaAdd();
<?php } ?>
</script>
